package com.xieyunjie.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;

/**
 * @program: 0812springboot
 * @author: 雷哥
 * @create: 2019-12-16 11:35
 **/
@Aspect
@Component
@EnableAspectJAutoProxy  //这个可以不加
public class ManAspect2 {


    //声明切面
    public static final String POINTCUT1="execution(* com.xieyunjie.domain.Man.sleep(..))";

    //@Before(POINTCUT1)
    public void before(){
        System.out.println("喝汤");
    }
    //@After(POINTCUT1)
    public void after(){
        System.out.println("搞一根");
    }

    @Around(POINTCUT1)
    public  Object around(ProceedingJoinPoint pjp) throws Throwable {

        Object[] args = pjp.getArgs();
        Object arg = args[0];
        System.out.println(arg);
        before();
        Object proceed = pjp.proceed();//执行目标方法
        after();
        return proceed;
    }



}
